package com.github.eclipseace.mybatis.entity.mapping;

import org.apache.ibatis.type.JdbcType;

import com.github.eclipseace.mybatis.util.Assert;

/**
 * @author eclipseAce
 */
public class PropertyMapping {
	private final String name;
	private final Class<?> type;
	private final String column;
	private final JdbcType jdbcType;
	private final boolean insertable;
	private final boolean updatable;

	public PropertyMapping(String name, Class<?> type, String column, JdbcType jdbcType, boolean insertable,
			boolean updatable) {
		Assert.isNotEmpty(name, "name is null or empty");
		Assert.isNotNull(type, "type is null");
		Assert.isNotEmpty(column, "column is null or empty");

		this.name = name;
		this.type = type;
		this.column = column;
		this.jdbcType = jdbcType != null ? jdbcType : JdbcType.UNDEFINED;
		this.insertable = insertable;
		this.updatable = updatable;
	}

	public String getName() {
		return name;
	}

	public Class<?> getType() {
		return type;
	}

	public String getColumn() {
		return column;
	}

	public JdbcType getJdbcType() {
		return jdbcType;
	}

	public boolean isInsertable() {
		return insertable;
	}

	public boolean isUpdatable() {
		return updatable;
	}
}
